﻿@{
    Layout = null;
}

<!doctype html>

<html>
<head>    
	<meta charset="utf-8">
	<title>@ViewBag.title</title>
    <link href="~/themes/kingmenu/res/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <script src="~/scripts/miniui/boot.js" type="text/javascript"></script>
    <link href="~/themes/kingmenu/res/third-party/scrollbar/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />
    <script src="~/themes/kingmenu/res/third-party/scrollbar/jquery.mCustomScrollbar.concat.min.js" type="text/javascript"></script>
    <link href="~/themes/res/tabs.css" rel="stylesheet" type="text/css" />
    <script src="~/scripts/common/print.js" type="text/javascript"></script>

    <link href="~/themes/kingmenu/res/css/index.css" rel="stylesheet" type="text/css" />
    <link href="~/themes/kingmenu/res/menu/menu.css" rel="stylesheet" type="text/css" />
    <script src="~/themes/kingmenu/res/menu/menu.js" type="text/javascript"></script>
    <script src="~/themes/kingmenu/res/menu/menupop.js" type="text/javascript"></script>
    <script src="~/scripts/common/PopUpWindow.js" type="text/javascript"></script>
</head>
<body>
    
<div class="navbar">
    <a class="navbar-left">
          <img src="@ViewBag.logo" class="navbar-logo" />
    </a>
    <ul class="navbar-right navbar-nav">
        <li class="navbar-nav-pay">
            <i class="fa fa-apply"></i>
            <span><a href="javascript:showTabByAppCenter()" style="color:white">应用中心</a></span>
        </li>
        <li class="navbar-nav-pay">
            <i class="fa fa-cashier"></i>
            <span><a href="../downloadpage/download.html" style="color:white" target="_blank">下载中心</a></span>
        </li>
        <li class="navbar-nav-pay">
            <i class="fa fa-market"></i>
            <!--<span><a href="javascript:LoginMall()" style="color:white">电商管理</a></span>-->
            <span><a href="http://doc.pos08.com" style="color:white" target="_blank">在线帮助</a></span>
        </li>
        <li class="navbar-nav-pay">
            <i class="fa fa-apply"></i>
            <span><a href="javascript:showTabBySMS()" style="color:white">短信充值</a></span>
        </li>
        <li class="navbar-nav-pay" style="float:right;color:white;padding-left:0px;" id="exit" onclick="Quit()">
            <i class="fa fa-sign-out" style="padding-left:15px;border-left: 2px solid #175D28;"></i>
            <span style="border-right: none"><a href=" " style="color:white">退出</a></span>
        </li>
        <li class="userInfo-img">
            <a class="userInfo-img-wrap">
                <img id="Headpart" src="../themes/kingmenu/img/head1.jpg" />
            </a>
        </li>
        <li class="navbar-nav-draopdown dropdown" style="min-width: 100px;width:auto;">
            <div class="userInfo dropdown-toggle">
                <div class="userInfo-top">@ViewBag.company</div>
                <span class="userInfo-bottom" href="#">@ViewBag.FAppName</span>
                <i class="fa fa-sort-down"> </i>
            </div>
            <ul class="dropdown-menu pull-right" style="top: 43px;">
                <li><a href="#" onclick="SetMyUsed()"><i class="fa fa-share-alt"></i>设置常用</a></li>
                <li><a href="#" onclick="EditPwd()"><i class="fa fa-edit"></i>修改密码</a></li>
                <li><a href="../helps/YunShopHelp.pdf" target="_blank"><i class="fa fa-book"></i>使用手册</a></li>
                <li class="divider"></li>
                <li><a href="javascript:SetActionCode()"><i class="fa fa-eye"></i>系统激活</a></li>
                <li class="divider"></li>
                <li><a href="javascript:UpdateInfo()"><i class="fa fa-plug"></i>升级公告</a></li>
                <li class="divider"></li>
                <li><a href="javascript:WxMessageList()"><i class="fa fa-book"></i>消息日志</a></li>
                <li class="divider"></li>
                <li><a href="#" onclick="Quit()"><i class="fa fa-user"></i> 退出系统</a></li>
            </ul>
        </li>

        <!--<li class="navbar-nav-pay fr">
        <i class="fa fa-entry"></i>
        <span>进入前台</span>
    </li>-->
    </ul>    
</div>

<div class="container">
    
    <div class="sidebar" id="sidebar1"></div>

    <div class="main">
        <div id="mainTabs" class="mini-tabs main-tabs" activeIndex="0" style="height:100%;" plain="false"
             buttons="#tabsButtons" maskOnLoad='false' arrowPosition="side"  contextMenu="#tabsMenu">
            <div name="tabdesktop" title=系统导航</div>
        </div>
    </div>   
</div>

    <ul id="tabsMenu" class="mini-contextmenu" onbeforeopen="onBeforeOpen">        
        <li onclick="closeTab">关闭标签页</li>                
	    <li onclick="closeAllBut">关闭其他标签页</li>
	    <li onclick="closeAll">关闭所有标签页</li>        
    </ul>

    <input type="hidden" id ="FSystemAppID" name="FSystemAppID" value="@ViewBag.FSystemAppID" />
    <input type="hidden" id ="FAppName" name="FAppName" value="@ViewBag.FAppName" />
    <input type="hidden" id ="FAppCode" name="FAppCode" value="@ViewBag.FAppCode" />
    <input type="hidden" id ="FCompany" name="FCompany" value="@ViewBag.company" />    
</body>
</html>
<script>
    mini.parse();

    var tabs = mini.get("mainTabs");
    function activeTab(item) {
        //showTabById(item.id, item.text, item.url);
        showTabByIdEx(item.pageid, item.id, item.text, item.url);
    }

    function SetActionCode() {
        mini.open({
            url: "/System/SetSysActivation",
            title: "系统激活", width: 720, height: 350,
            onload: function () {
            },
            ondestroy: function (action) {
                if (action == "recharge") {
                    //showTabById('Terminal', '充值续费', '../System/Terminal');
                    showTabById("134_Terminal", "充值续费", "../AppCenter/Terminal");
                };
            }
        });
    }

    function LoginMall() {
        var mUrl = "http://web.pos08.com/#/login?username=admin&password=" + getSystemAppID();
        window.open(mUrl, "_blank");
    }

    $(function () {
        //menu
        var menu = new Menu("#sidebar1", {
            itemclick: function (item) {
                if (!item.children) {
                    activeTab(item);
                }
            }
        });

        //$(".sidebar").mCustomScrollbar({ autoHideScrollbar: true });

        new MenuPop(menu);

        var Height;
        var Li;

        window.onresize = function () {
            Height = $(window).height();
            var ul = $('.has-children').find('.menu-submenu');
            for (var i = 0; i < ul.length; i++) {
                var height = $(ul[i]).innerHeight();
                var Width = $(ul[i]).innerWidth();

                Li = $(ul[i]).find('li');
                var Wh = (Width * 2);
                if (height > Height) {
                    $(ul[i]).css({ 'width': Wh + 'px' });
                    $(Li).css({ 'width': Width + 'px', 'float': 'left' });
                } else {
                    $(ul[i]).css({ 'width': 'auto' });
                }
            }
        }

        var uID = getSystemAppID();
        $.ajax({
            url: "../Home/GetUserMenu",
            data: { mSystemAppID: uID },
            success: function (text) {
                var data = mini.decode(text);
                menu.loadData(data);

                Height = $(window).height();
                var ul = $('.has-children').find('.menu-submenu');
                for (var i = 0; i < ul.length; i++) {
                    var height = $(ul[i]).innerHeight();
                    var Width = $(ul[i]).innerWidth();

                    Li = $(ul[i]).find('li');
                    var Wh = (Width * 2);
                    if (height > Height) {
                        $(ul[i]).css({ 'width': Wh + 'px' });
                        $(Li).css({ 'width': Width + 'px', 'float': 'left' });
                    } else {
                        $(ul[i]).css({ 'width': 'auto' });
                    }
                }                
            }
        })

        //dropdown
        $(".dropdown-toggle").click(function (event) {
            $(this).parent().addClass("open");
            return false;
        });

        $(document).click(function (event) {
            $(".dropdown").removeClass("open");
        });

        //鼠标移入移出
        $('.userInfo').on({
            mouseover: function () {
                $(this).siblings().css('display', 'block');
                //$(this).parent().addClass("open");
            },
            mouseout: function () {
                $(this).siblings().css('display', 'none');
            }
        })
        $(".dropdown-menu").on({
            mouseover: function () {
                $(this).css('display', 'block');
            },
            mouseout: function () {
                $(this).css('display', 'none');
            }
        })

        $(".navbar-toggle").bind("click", function (e) {
            e.stopPropagation();
            var width = $(".navbar-left").width();
            if (width == 62) {
                $(".navbar-left").width(160);
                $(".sidebar >ul >li >a > span.menu-text").show();
                $(".navbar").css({ "backgroundColor": "#4664e6", "color": "#fff" });
                $(".main").css({ "left": 175 });
            } else {
                $(".navbar-left").width(62);
                $(".sidebar >ul >li >a > span.menu-text").hide();
                $(".navbar").css({ "backgroundColor": "#fff", "color": "#666" });
                $(".main").css({ "left": 77 });
            }
        });

        loadDesktop();
        //UserInfo();

        $.post("../Home/GetStockWarning", { mjson: "[{'mSystemAppID':'" + uID + "'}]" }, function (data) {
            var Data = mini.decode(data);
            if (Data.status == 1) {
                var str = "<a href=\"javascript:showTabById('RptStockWarning','库存警报','../report/RptStockWarning')\" class=\"titName\">有库存低于最低预警线, 点击查看</a>";
                ShowMsg.setContent(str);
                ShowMsg.show();
            }
        });

        //$('#exit').click(function (e) {
        //    e.stopPropagation();
        //    $.post("Home/Quit", {}, function (data) {
        //        $("#FSystemAppID").val("");
        //        window.location.href = "Home/Login";
        //    });
        //});
    });

    function loadDesktop() {
        var tab = tabs.getTab("tabdesktop");
        tabs.loadTab("../Home/indexdesktop", tab);
    }

    function getMyImportLog(msg) {
        mini.alert(msg);
    }

    function getSystemAppID() {
        var mySysAppID = $("#FSystemAppID").val();
        return mySysAppID;
    }
        

    function getSystemCompany() {
        var mySysCompany = $("#FCompany").val();
        return mySysCompany;
    }

    function getSystemAppName() {
        var mySysAppName = $("#FAppName").val();
        return mySysAppName;
    }

    function getSystemAppCode() {
        var mySysAppCode = $("#FAppCode").val();
        return mySysAppCode;
    }

    function showTabById(tabid, tabtext, url) {
        if (tabid == "134_Terminal") {
            url = url + "?FSystemAppID=" + getSystemAppID();
        }
        //else {
        //    if (url.indexOf("?") != -1) {
        //        url = url + "&FSystemAppID=" + getSystemAppID();
        //    } else {
        //        url = url + "?FSystemAppID=" + getSystemAppID();
        //    }
        //}

        var id = "tab$" + tabid;
        var tab = tabs.getTab(id);
        if (!tab) {
            tab = {};
            tab.name = id;
            tab.title = tabtext;
            tab.showCloseButton = true;
            tab.url = url;
            tabs.addTab(tab);
        }
        tabs.activeTab(tab);
    }

    function showTabByIdEx(pageid, tabid, tabtext, url) {
        if (pageid == 8801) {
            window.open(url, "_blank");
        } else {
            if (url.indexOf("?") != -1) {
                url = url + "&FSystemAppID=" + getSystemAppID() + "&pageid=" + pageid;
            } else {
                url = url + "?FSystemAppID=" + getSystemAppID() + "&pageid=" + pageid;
            }
            var id = "tab$" + tabid;
            var tab = tabs.getTab(id);
            if (!tab) {
                tab = {};
                tab.name = id;
                tab.title = tabtext;
                tab.showCloseButton = true;
                tab.url = url;
                tabs.addTab(tab);
            }
            tabs.activeTab(tab);
        }
    }

    function showTabByAppCenter() {
        showTabById('AppCenter', '应用中心', '../AppCenter?FSystemAppID=' + getSystemAppID());
    }
    function showTabBySMS() {
        showTabById('RechargeSMS', '充值短信', '../System/RechargeSMS');
    }

    var HSonCorp = -1;
    $(function () {
        $.post("../corp/corpisorg", { mjson: getSystemAppID() }, function (data) {
            HSonCorp = data;
        });
        var uname = getSystemAppName();
        $("#username").html(uname);
    });

    function SonCorp() {
        return HSonCorp;
    }

    function Quit(e) {
        $.post("Home/Quit", {}, function (data) {
            $("#FSystemAppID").val("");
            window.location.href = "Home/Login";
        });
    }

    function onBeforeOpen(e) {
        currentTab = tabs.getTabByEvent(e.htmlEvent);
        if (!currentTab) {
            e.cancel = true;
        }
    }

    function closeTab() {
        if (currentTab.name != 'tabdesktop') {
            tabs.removeTab(currentTab);
        }
    }

    function closeAllBut() {
        var but = [currentTab];
        but.push(tabs.getTab("tabdesktop"));
        tabs.removeAll(but);
    }

    function closeAll() {
        var tab = tabs.getTab("tabdesktop");
        tabs.removeAll(tab);
    }

    function EditPwd() {
        mini.open({
            url: "/User/EditPwd",
            title: "密码修改", width: 430, height: 320,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "edit", FItemID: "-1" };
                iframe.contentWindow.SetInfoData(data);
            },
            ondestroy: function (action) {
                //var grid = mini.get("datagrid1");
                //grid.reload();
            }
        });
    }

    function SetMyUsed() {
        showTabById('BaseUrlUsed', '设置常用', '../Power/BaseUrlUsed');
    }

    function UpdateInfo() {
        showTabById('UpdateInfoList', '升级公告', '../UpdateInfo/UpdateInfoList');
    }

    function WxMessageList() {
        showTabById('WxMessageList', '消息日志', '../UpdateInfo/WxMessageList');
    }
</script>